#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int minlen = 100;
        for (auto& str : strs) {
            if (minlen > str.size())
                minlen = str.size();
        }
        int m = strs.size();
        int a = 1;
        int i = 0;
        for (i = 0; i < minlen; i++) {
            char t = strs[0][i];
            for (int j = 0;j < m;j++)
            {
                if (t != strs[j][i])
                {
                    a = 0;
                    break;
                }
            }
            if (a == 0)break;
        }
        if (i == 0) return "";
        else return strs[0].substr(0, i);
    }
};